<?php

namespace App\Http\Middleware;

use App\Facades\UserService;
use Closure;
use Response;
use Sentinel;

class Admin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user = Sentinel::getUser();
        if($request->is('*/login') || $user->is_admin)
        {   
            return $next($request);
        }
        return Response::make(view('admin/errors/hint', ['status' => config('exceptions.user.admin')]));
        // return redirect('admin/user/login');
    }
}
